package main

import (
	"github.com/gin-gonic/gin"
	"log"
	"time"
)

type service struct{}

func (s *service) Hello(ctx *gin.Context) {
	ctx.JSON(200, gin.H{"hello": "world"})
}

func (s *service) Time(ctx *gin.Context) {
	ctx.JSON(200, gin.H{"time": time.Now()})
}

func main() {
	svc := &service{}
	router := gin.Default()
	router.GET("/hello", svc.Hello)
	router.GET("/time", svc.Time)

	if err := router.Run(":8080"); err != nil {
		log.Fatal(err)
	}
}
